/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package aplicacaoPlano;

import br.edu.GenericDAO;
import br.edu.HibernateUtil;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.criterion.Restrictions;
import vacina.Vacina;

/**
 *
 * @author Max Weber
 */

    
public class AplicacaoPlanoDAO extends GenericDAO<AplicacaoPlano>{
    //cria uma sessão
    private Session sessao;
    //abre uma transação
    private Transaction transacao;
    
    public AplicacaoPlanoDAO(){
        super(AplicacaoPlano.class);
    }
    
    
    
    public AplicacaoPlano pesquisarCodigo(int codigo) {
        sessao = HibernateUtil.getSessionFactory().openSession();
        transacao = sessao.beginTransaction();

        AplicacaoPlano planoAlplicacao
                = (AplicacaoPlano) sessao.createCriteria(AplicacaoPlano.class).add(Restrictions.eq("id", codigo)).uniqueResult();
        sessao.close();
        return planoAlplicacao;
    }
    
}
